package com.jay.utils;

import java.net.MalformedURLException;
import java.net.URL;

/**
 * Created by caoyuan7 on 2018/4/13.
 */
public abstract class FileURL {
    protected FileURL() {
    }

    public static URL makeURL(String pathname) throws MalformedURLException {
        if(pathname.startsWith("/")) {
            return new URL("file://" + pathname);
        } else {
            String userdir = System.getProperty("user.dir");
            userdir = userdir.replace('\\', '/');
            return userdir.endsWith("/")?new URL("file:///" + userdir + pathname):new URL("file:///" + userdir + "/" + pathname);
        }
    }
}
